<template>
    <div class="sub-menu">
      <template v-for="item in menuList">
        <!-- 最后一级菜单 -->
        <el-menu-item v-if="!item.children" :key="item.id" :data="item" :index="item.name" :route="item.url">
          <i :class="item.icon"></i>
          <span slot="title">{{item.alias}}</span>
        </el-menu-item>
        <!-- 此菜单下还有子菜单 -->
        <el-submenu v-if="item.children" :key="item.id" :data="item" :index="item.name">
          <template slot="title">
            <i :class="item.icon"></i>
            <span>{{item.alias}}</span>
          </template>
          <!-- 递归 -->
          <sub-menu :menu-list="item.children"></sub-menu>
        </el-submenu>
      </template>
    </div>
</template>

<script>
export default {
  name: 'SubMenu',
  props: {menuList: Array},
  data () {
    return {

    }
  }
}
</script>

<style scoped>

</style>
